package com.oss;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

/**
 * 版权所有 泰山信息技术有限公司
 *
 * @Author: yuhaitao
 * @Date 2020/5/14 10:58 上午
 */
@Data
public class R<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> R<T> success(T data) {
        R<T> r = new R<>();
        r.code = 0;
        r.msg = null;
        r.data = data;
        return r;
    }

    public static <Void> R<Void> faile(int code, String msg) {
        R<Void> r = new R<>();
        r.code = code;
        r.msg = msg;
        r.data = null;
        return r;
    }

    @JsonIgnore
    public boolean isSuccess() {
        return code == 0;
    }
}
